package com.maple.sdk.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.maple.sdk.entity.TSystemRole;
import com.maple.sdk.service.IRoleService;

/**
 * @Description RoleControll
 * @author 李铭浩
 * @Date 2012-11-6
 * @Porject  BasicRole
 */
@Controller
@RequestMapping("/role")
public class RoleController extends BaseController {
	@Autowired
	@Qualifier(value="IRoleService")
	private IRoleService roleService;
	
	@RequestMapping(params="findRoleList")
	public String findRoleList(HttpServletRequest request){
		List<TSystemRole> list = roleService.findRoleList();
		//暂不能用
//		ModelMap modelMap = new ModelMap();
//		modelMap.put("roleList", list);
		request.setAttribute("roleList", list);
		return "/role/rolePage";
	}
	@RequestMapping(params="savePage")
	public String savePage(){
		return "/role/add_role";
	}
	@RequestMapping(params="saveRole")
	public ModelAndView saveRole(HttpServletRequest request,TSystemRole role){
		this.roleService.saveRole(role);
		ModelAndView mv = new ModelAndView();
		//mv.addObject("page", page);
		mv.setViewName("redirect:/role.do?findRoleList");
		return mv;
	}
	public IRoleService getRoleService() {
		return roleService;
	}
	public void setRoleService(IRoleService roleService) {
		this.roleService = roleService;
	}
	
}
